@import '~@hi-ui/core-css/lib/index.scss';

$prefix: '#{$component-prefix}-form' !default;

.#{$prefix} {
  max-width: 100%;
  position: relative;

  fieldset {
    margin: 0;
    padding: 0;
    border: 0;

    & + fieldset {
      margin-top: 16px;
    }
  }

  legend {
    margin: 0 0 16px;
    color: use-color('gray', 800);
  }

  &--placement {
    &-horizontal {
      display: flex;
      flex-wrap: wrap;
      column-gap: use-spacing(10);

      // 上下布局只在水平表单中自动填充高度
      .#{$prefix}-label__indent {
        min-height: use-height-size(8);
      }
    }
  }
}

.#{$prefix}-label {
  font-size: use-text-size('normal');
  box-sizing: border-box;
  margin-right: 0;

  &__content {
    display: flex;

    .#{$prefix}-label--placement-top > & {
      text-align: left;
      flex-direction: column;
      padding-right: 0;
    }

    &__text,
    &__indent {
      flex-shrink: 0;
      box-sizing: border-box;
      vertical-align: top;
      color: use-color('gray', 800);
      overflow-wrap: break-word;
    }

    &__text {
      padding-right: use-spacing(6);
      min-height: use-height-size(8);
      line-height: use-height-size(8);

      .#{$prefix}-label--placement-left > .#{$prefix}-label__content > & {
        text-align: left;
      }

      .#{$prefix}-label--placement-right > .#{$prefix}-label__content > & {
        text-align: right;
      }

      .#{$prefix}-label--placement-top > .#{$prefix}-label__content > & {
        min-height: 22px;
        line-height: 22px;
        padding-right: 0;
        margin-bottom: use-spacing(4);
      }

      .#{$prefix}-label--required > .#{$prefix}-label__content > & {
        &::before {
          margin-right: use-spacing(2);
          content: '*';
          color: use-color-mode('error');
        }
      }
    }

    &__control {
      // 适应容器 flex 宽度，不被内部撑开
      min-width: 1px;
    }
  }
}

.#{$prefix}-message {
  display: block;
  font-size: use-text-size('normal');
  min-height: 24px;
  padding: 2px 0;
  box-sizing: border-box;
  line-height: 20px;
  transform: translateY(-10%);
  opacity: 0;
  color: use-color-mode('error');
  // TODO: 动效
  transition: all 0.3s;

  &--show {
    opacity: 1;
    transform: translateY(0);
  }
}

.#{$prefix}-item {
  position: relative;
}
